﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace FPSO.HMI.Controls
{
    /// <summary>
    /// UCMenu.xaml 的交互逻辑
    /// </summary>
    public partial class UCMenu : UserControl
    {
        public UCMenu()
        {
            InitializeComponent();
        }

        private void BtnMenu_Click(object sender, RoutedEventArgs e)
        {
            Button btnMenu = (Button)sender;
			int menuPos = ((Button)sender).TabIndex;
			string menuName = ((Button)sender).Content.ToString();
            Style normalStyle = (Style)this.FindResource("MenuItemNormal");
            Style activeStyle = (Style)this.FindResource("MenuItemActive");

            foreach(UIElement ui in menuPanel.Children)
            {
                if (ui is Button btn)
                {
                    if (btn == btnMenu)
                    {
                        btn.Style = activeStyle;
                    }
                    else
                    {
                        btn.Style = normalStyle;
                    }
                }
            }

            OnMenuChanged?.Invoke(menuPos);
        }

        [Category("Action")]
        [Description("选中的菜单项修改")]
        //public event Action<string> OnMenuChanged;
		public event Action<int> OnMenuChanged;
	}
}
